package com.meima.controller;

import com.meima.entity.PersonProperties;
import com.meima.entity.User;
import com.meima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
//@RefreshScope
public class UserController {

    @Autowired
    UserService userService;

//    @Value("${person.name}")
//    String name;

    @Autowired
    PersonProperties personProperties;

//    @RequestMapping("getById")
    @GetMapping("/{id}")
    public User findById(@PathVariable Long id){
        System.out.println("-----------------你好，我被访问了---------------");
        return userService.findById(id);
    }

    @GetMapping("name")
    public String name(){
        return "你好，"+personProperties.getName()+"欢迎回来~";
    }

    @GetMapping("person")
    public PersonProperties person(){
        return personProperties;
    }
}
